package com.nageoffer.shortlink.admin.toolkit;

import java.util.Random;

public final class RandomGenerator {
    // 可选字符池（包含大写字母、小写字母、数字）
    private static final String CHAR_POOL = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

    private static final Random RANDOM = new Random();

    /**
     * 生成6位随机字符串（数字 + 字母）
     *
     * @return 随机字符串，如：a9ZxK3
     */
    public static String generateCode() {
        StringBuilder sb = new StringBuilder(6);
        for (int i = 0; i < 6; i++) {
            int index = RANDOM.nextInt(CHAR_POOL.length());
            sb.append(CHAR_POOL.charAt(index));
        }
        return sb.toString();
    }
}
